home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Interactive 7
/
PC World Interactive 7.iso
/
program
/
ctutord.EXE
/
AUTO_FLA.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-10
|
1KB
|
53 lines
#define ON 0x01
#define OFF 0x00
#define RADIO_ON 0x01
#define HORN_ON 0x02
#define LIGHTS_ON 0x04
#define BRAKES_ON 0x08
#define RADIO_OFF ~RADIO_ON
#define HORN_OFF ~HORN_ON
#define LIGHTS_OFF ~LIGHTS_ON
#define BRAKES_OFF ~BRAKES_ON
void status(char);
void main()
{
char auto_flag=0;
/* BRAKES and LIGHTS are ON */
auto_flag = auto_flag | BRAKES_ON ;
auto_flag = auto_flag | LIGHTS_ON ;
status(auto_flag);
/* Now change the status...
BRAKES are OFF, RADIO is ON */
auto_flag = auto_flag | RADIO_ON;
auto_flag = auto_flag & BRAKES_OFF;
status(auto_flag);
}
void status(char auto_flag)
{
if( auto_flag&RADIO_ON)
printf("RADIO is ON\n");
else
printf("RADIO is OFF\n");
if( auto_flag&HORN_ON)
printf("HORN is ON\n");
else
printf("HORN is OFF\n");
if( auto_flag&LIGHTS_ON)
printf("LIGHTS is ON\n");
else
printf("LIGHTS is OFF\n");
if( auto_flag&BRAKES_ON)
printf("BRAKES is ON\n");
else
printf("BRAKES is OFF\n");
}